package com.xrz.sxm.aj.activity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SlidingDrawer;
import android.widget.SlidingDrawer.OnDrawerCloseListener;
import android.widget.SlidingDrawer.OnDrawerOpenListener;
import android.widget.TextView;

import com.lidroid.xutils.view.annotation.ViewInject;
import com.xrz.sxm.aj.adapter.DrawerAdapter;
import com.xrz.sxm.aj.base.BaseAct;
import com.xrz.sxm.aj.cons.BuWei;
import com.xrz.sxm.aj.entity_tab.DBHelps;
import com.xrz.sxm.aj.utils.BaseDialog.onDialogBtnClickListener;
import com.xrz.sxm.aj.utils.ExitUtil;
import com.xrz.sxm.aj.utils.ScreenUtil;
import com.xrz.sxm.aj.view.ScrollListenerHorizontalScrollView;
import com.xrz.sxm.aj.view.ScrollListenerHorizontalScrollView.ScrollType;
import com.xrz.sxm.aj.view.ScrollListenerHorizontalScrollView.ScrollViewListener;
import com.xrz.sxm.aj.view.TouchImageView;
import com.xrz.sxm.aj.view.TouchRelativeLayout;

import java.util.ArrayList;
import java.util.List;

public class Act_Main extends BaseAct implements OnClickListener,
		OnDrawerOpenListener, OnDrawerCloseListener, ScrollViewListener,
		Runnable, OnItemClickListener {
	// 全身
	@ViewInject(R.id.tv_quanshen)
	private TextView tv_quanshen;
	// 头
	@ViewInject(R.id.tv_tou)
	private TextView tv_tou;
	// 颈
	@ViewInject(R.id.tv_jing)
	private TextView tv_jing;
	// 肩
	@ViewInject(R.id.tv_jian)
	private TextView tv_jian;
	// 胸
	@ViewInject(R.id.tv_xiong)
	private TextView tv_xiong;
	// 背
	@ViewInject(R.id.tv_bei)
	private TextView tv_bei;
	// 全身1
	@ViewInject(R.id.tv_quanshen1)
	private TextView tv_quanshen1;

	/** 包裹人体图片的容器 */
	@ViewInject(R.id.rtly_content)
	private TouchRelativeLayout m_RelativeLayout;
	/** 翻转的按钮 */
	@ViewInject(R.id.btn_fanzhuan)
	private Button m_btn_fanzhuan;
	/** 查询的按钮 */
	@ViewInject(R.id.btn_search)
	private Button m_btn_search;
	/** 当前的方向是不是前方 */
	private boolean m_isFront = true;
	/** 前面部分的图片资源 */
	private List<Integer> m_front_ress;
	/** 后面部分的图片资源 */
	private List<Integer> m_back_ress;
	/** 记录手指落下的坐标 */
	private int downx, downy;
	/** 是否点击到了部位 */
	private boolean touch = true;
	/** 广播接收器 */
	private MoveReceiver m_MoveReceiver;
	/** 隐藏抽屉的Handler */
	private static final LayoutParams params = new LayoutParams(0,
			LayoutParams.WRAP_CONTENT);
	/** 抽屉 */
	@ViewInject(R.id.slidingdrawer)
	private SlidingDrawer m_SlidingDrawer;
	/** 抽屉的handler */
	@ViewInject(R.id.slideing_handler)
	private ImageView m_sliding_handler;
	/** 抽屉中的ListView */
	@ViewInject(R.id.drawer_list)
	private ListView m_slide_lv;
	/** 抽屉中的ListView的适配器 */
	private DrawerAdapter m_DrawerAdapter;
	/** 抽屉ListView的数据 */
	private List<String> m_Slider_Datas;
	/** 充当抽屉的handler */
	@ViewInject(R.id.iv_handler)
	private ImageView m_iv_handler;
	/** 抽屉打开后，充当抽屉的handler */
	@ViewInject(R.id.open_drawer)
	private TextView m_open_drawer;
	@ViewInject(R.id.gallery_bottom)
	private ScrollListenerHorizontalScrollView m_ScrollView;
	/** 屏幕的宽度 */
	private int m_DisWidth;
	/** 底部菜单按钮的宽度参数 */
	private LayoutParams m_bottom_btn_params;
	/** scrollview需要的handler */
	private Handler m_Handler = new Handler();
	/** Scrollview包含的LinearLayout */
	@ViewInject(R.id.bottom_linearlayout)
	private LinearLayout m_Bottom_LinearLayout;
	/** 自动播放的时间 */
	private static final int TIME = 7000;

	private Intent m_Skip_Buwei_Intent;

	/** 当前选择的部位 */
	private BuWei m_BuWei;

	@ViewInject(R.id.about_qiye)
	private TextView Btn_aboutQiye;
	public static final int ZHENGZHUANGTYPE = 2;
	private Button Btn1, Btn2, Btn3, Btn4, Btn5, Btn6;
	private Intent intent;
	public String TYPE_LIAOFA;

	/** 搜索框 */
	@ViewInject(R.id.edt_bing)
	private AutoCompleteTextView edt_bing;
	/** 搜素关键词列表 */
	private List<String> m_Search_keys = new ArrayList<String>();
	/** popup的适配器 */
	private ArrayAdapter<String> m_Search_Adapter;

	private DBHelps m_DbHelps;

	@ViewInject(R.id.tv_search)
	private TextView tv_search;
	@ViewInject(R.id.tv_ceshi)
	private TextView tv_ceshi;
	@ViewInject(R.id.tv_search_xuewei)
	private TextView tv_search_xuewei;
	@ViewInject(R.id.btn_gushi)
	private TextView btn_gushi;
	@Override
	protected int setView() {
		return R.layout.layout_main;
	}


	@Override
	protected void init() {
		m_DbHelps= new DBHelps(ctx);
		m_Search_keys = m_DbHelps.getKeys();
		m_Search_Adapter = new ArrayAdapter<String>(ctx, R.layout.list_item_1,
				m_Search_keys);
		edt_bing.setAdapter(m_Search_Adapter);
		m_DisWidth = ScreenUtil.getInstant().getDisWidth(ctx);
		m_bottom_btn_params = new LayoutParams(m_DisWidth / 3,
				LayoutParams.WRAP_CONTENT);
		m_iv_handler.setOnClickListener(this);
		m_open_drawer.setOnClickListener(this);
		Btn_aboutQiye.setOnClickListener(this);
		regReceiver();
		m_ScrollView.setHandler(m_Handler);
		m_ScrollView.setOnScrollStateChangedListener(this);
		m_front_ress = new ArrayList<Integer>();
		m_back_ress = new ArrayList<Integer>();
		m_btn_fanzhuan.setOnClickListener(this);
		m_btn_search.setOnClickListener(this);
		tv_quanshen.setOnClickListener(this);
		tv_tou.setOnClickListener(this);
		tv_jing.setOnClickListener(this);
		tv_jian.setOnClickListener(this);
		tv_xiong.setOnClickListener(this);
		tv_bei.setOnClickListener(this);
		tv_search.setOnClickListener(this);
		tv_quanshen1.setOnClickListener(this);
		tv_search_xuewei.setOnClickListener(this);
		tv_ceshi.setOnClickListener(this);
		findViewById(R.id.tv_tuijian).setOnClickListener(this);
		btn_gushi.setOnClickListener(this);
		reset(true, false, R.mipmap.bo_bo_tou1_sel);
		initDrawerListViewData();
		createBottomView();
		m_Handler.postDelayed(this, TIME);
	}
	/**搜索按钮*/
	private void onsearchClick(){
		if(edt_bing.getText().toString().trim().equals("")){
			toastLong("请输入疾病名字");
			return;
		}
		startActivity(new Intent(this, LiaoFaActivity.class).putExtra("title", "搜索症状").putExtra("type", edt_bing.getText().toString().trim()));
	}

	/** 测试按钮 */
	private void onTestClick() {
		startActivity(new Intent(this, Act_Test.class));
	}

	/**
	 * 搜索穴位
	 */
	public void search_xuewei(){
		Intent intent = new Intent(this, Act_Search_xuewei.class);
		startActivity(intent);
	}

	private void createBottomView() {
		Btn1 = createBtn("中老年慢性病艾灸疗法", R.drawable.selector_main_bottom_zln, 1);
		Btn2 = createBtn("美容美体艾灸疗法", R.drawable.selector_main_bottom_mt, 2);
		Btn3 = createBtn("养生保健艾灸疗法", R.drawable.selector_main_bottom_bj, 3);
		Btn4 = createBtn("常见男科病艾灸疗法", R.drawable.selector_main_bottom_nk, 4);
		Btn5 = createBtn("常见妇科病艾灸疗法", R.drawable.selector_main_bottom_fk, 5);
		Btn6 = createBtn("艾灸常识", R.drawable.selector_main_bottom_cs, 6);
		Btn1.setOnClickListener(this);
		Btn2.setOnClickListener(this);
		Btn3.setOnClickListener(this);
		Btn4.setOnClickListener(this);
		Btn5.setOnClickListener(this);
		Btn6.setOnClickListener(this);
		m_Bottom_LinearLayout.addView(Btn1);
		m_Bottom_LinearLayout.addView(Btn2);
		m_Bottom_LinearLayout.addView(Btn3);
		m_Bottom_LinearLayout.addView(Btn4);
		m_Bottom_LinearLayout.addView(Btn5);
		m_Bottom_LinearLayout.addView(Btn6);
	}

	private Button createBtn(String text, int res, int id) {
		Button btn = new Button(ctx);
		btn.setTextColor(Color.WHITE);
		btn.setTextSize(10);
		btn.setLayoutParams(m_bottom_btn_params);
		btn.setBackgroundColor(Color.TRANSPARENT);
		btn.setText(text);
		btn.setId(id);
		btn.setCompoundDrawablesWithIntrinsicBounds(res, 0, 0, 0);
		return btn;
	}

	private void regReceiver() {
		m_MoveReceiver = new MoveReceiver();
		IntentFilter filter = new IntentFilter();
		filter.addAction(TouchRelativeLayout.ACTION_MOVE_);
		filter.addAction(TouchRelativeLayout.ACTION_UP_);
		registerReceiver(m_MoveReceiver, filter);
	}

	private void initDrawerListViewData() {
		/** 设置handler隐藏 */
		m_sliding_handler.setLayoutParams(params);
		m_Slider_Datas = new ArrayList<String>();
		m_Slider_Datas.add("内科症状");
		m_Slider_Datas.add("妇科症状");
		m_Slider_Datas.add("儿科症状");
		m_Slider_Datas.add("外科症状");
		m_Slider_Datas.add("肛肠科症状");
		m_Slider_Datas.add("皮肤科症状");
		m_Slider_Datas.add("耳鼻喉症状");
		m_Slider_Datas.add("眼科症状");
		m_DrawerAdapter = new DrawerAdapter(ctx, m_Slider_Datas,
				ZHENGZHUANGTYPE);
		m_slide_lv.setAdapter(m_DrawerAdapter);
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		unregisterReceiver(m_MoveReceiver);
		m_Handler.removeCallbacks(this);
	}

	/** 重置前面的资源 */
	private void resetFrontListView() {
		m_front_ress.clear();
		m_front_ress.add(R.mipmap.bo_bo_fu_sel);
		m_front_ress.add(R.mipmap.bo_bo_jian1_sel);
		m_front_ress.add(R.mipmap.bo_bo_jing1_sel);
		m_front_ress.add(R.mipmap.bo_bo_shou1_sel);
		m_front_ress.add(R.mipmap.bo_bo_tou1_sel);
		m_front_ress.add(R.mipmap.bo_bo_tui1_sel);
		m_front_ress.add(R.mipmap.bo_bo_xiong_sel);
		m_front_ress.add(R.mipmap.bo_bo_yin_sel);
	}

	private void resetBackListView() {
		m_back_ress.clear();
		m_back_ress.add(R.mipmap.bo_bo_bei_sel);
		m_back_ress.add(R.mipmap.bo_bo_jian2_sel);
		m_back_ress.add(R.mipmap.bo_bo_jing2_sel);
		m_back_ress.add(R.mipmap.bo_bo_shou2_sel);
		m_back_ress.add(R.mipmap.bo_bo_tou2_sel);
		m_back_ress.add(R.mipmap.bo_bo_tui2_sel);
		m_back_ress.add(R.mipmap.bo_bo_gang_sel);
		m_back_ress.add(R.mipmap.bo_bo_yao_sel);
	}

	private void reset(boolean isFrist, boolean isSelect, int fristRes) {
		m_RelativeLayout.removeAllViews();
		int pos = 0;
		if (m_isFront) {
			resetFrontListView();
			pos = m_front_ress.indexOf(fristRes);
			m_front_ress.remove(pos);
			TouchImageView imageView;
			for (int i = 0; i < m_front_ress.size(); i++) {
				imageView = new TouchImageView(ctx);
				imageView.setImageResource(m_front_ress.get(i));
				imageView.setSelect(false);
				imageView.setOnTouchListener(new ImageTouchListener(
						m_front_ress.get(i)));
				m_RelativeLayout.addView(imageView);
			}
			imageView = new TouchImageView(ctx);
			imageView.setImageResource(isSelect ? R.mipmap.bo_bo_fro_sel
					: R.mipmap.bo_bo_fro);
			imageView.setSelect(isSelect);
			m_RelativeLayout.addView(imageView);
			imageView = new TouchImageView(ctx);
			imageView.setImageResource(fristRes);
			imageView.setOnTouchListener(new ImageTouchListener(fristRes));
			imageView.setSelect(isSelect ? false : true);
			m_RelativeLayout.addView(imageView);
		} else {
			resetBackListView();
			pos = m_back_ress.indexOf(fristRes);
			m_back_ress.remove(pos);
			TouchImageView imageView;
			for (int i = 0; i < m_back_ress.size(); i++) {
				imageView = new TouchImageView(ctx);
				imageView.setImageResource(m_back_ress.get(i));
				imageView.setSelect(false);
				imageView.setOnTouchListener(new ImageTouchListener(m_back_ress
						.get(i)));
				m_RelativeLayout.addView(imageView);
			}
			imageView = new TouchImageView(ctx);
			imageView.setImageResource(isSelect ? R.mipmap.bo_bo_bak_sel
					: R.mipmap.bo_bo_bak);
			imageView.setSelect(isSelect);
			m_RelativeLayout.addView(imageView);
			imageView = new TouchImageView(ctx);
			imageView.setImageResource(fristRes);
			imageView.setOnTouchListener(new ImageTouchListener(fristRes));
			imageView.setSelect(isSelect ? false : true);
			m_RelativeLayout.addView(imageView);
		}
		if (isSelect) {
			this.m_BuWei = BuWei.quanshen;
		} else {
			checkTouch(fristRes);
		}
		if (isFrist)
			return;
		// m_Handler.postDelayed(new SkipRunnable(), 200);
		m_Skip_Buwei_Intent = new Intent(ctx, Act_Buwei.class);
		m_Skip_Buwei_Intent.putExtra("data", m_BuWei);
	}

	private void checkTouch(int res) {
		switch (res) {
			case R.mipmap.bo_bo_bak_sel:
			case R.mipmap.bo_bo_fro_sel:
				// 选中的是全身
				this.m_BuWei = BuWei.quanshen;
				break;
			case R.mipmap.bo_bo_bei_sel:
				// 背部
				this.m_BuWei = BuWei.beibu;
				break;
			case R.mipmap.bo_bo_fu_sel:
				// 腹部
				this.m_BuWei = BuWei.fubu;
				break;
			case R.mipmap.bo_bo_gang_sel:
				// 肛部
				this.m_BuWei = BuWei.gangbu;
				break;
			case R.mipmap.bo_bo_jian1_sel:
			case R.mipmap.bo_bo_jian2_sel:
				// 肩部
				this.m_BuWei = BuWei.jianbu;
				break;
			case R.mipmap.bo_bo_jing1_sel:
			case R.mipmap.bo_bo_jing2_sel:
				// 颈部
				this.m_BuWei = BuWei.jingbu;
				break;
			case R.mipmap.bo_bo_shou1_sel:
			case R.mipmap.bo_bo_shou2_sel:
				// 手部
				this.m_BuWei = BuWei.shoubu;
				break;
			case R.mipmap.bo_bo_tou1_sel:
			case R.mipmap.bo_bo_tou2_sel:
				// 头部
				this.m_BuWei = BuWei.toubu;
				break;
			case R.mipmap.bo_bo_tui1_sel:
			case R.mipmap.bo_bo_tui2_sel:
				// 腿部
				this.m_BuWei = BuWei.tuibu;
				break;
			case R.mipmap.bo_bo_xiong_sel:
				// 胸部
				this.m_BuWei = BuWei.xiongbu;
				break;
			case R.mipmap.bo_bo_yao_sel:
				// 腰部
				this.m_BuWei = BuWei.yaobu;
				break;
			case R.mipmap.bo_bo_yin_sel:
				// 阴部
				this.m_BuWei = BuWei.yinbu;
				break;
		}
	}

	@Override
	protected String setTopTitle() {
		return null;
	}

	@Override
	protected boolean topHide() {
		return true;
	}

	public void zuixinzixun() {
		startActivity(new Intent(Act_Main.this, ZiXunActivity.class));
	}

	public void anli() {
		startActivity(new Intent(Act_Main.this, DianXinganliActivity.class));
	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
			case R.id.btn_fanzhuan:
				m_isFront = !m_isFront;
				reset(true, false, m_isFront ? R.mipmap.bo_bo_tou1_sel
						: R.mipmap.bo_bo_tou2_sel);
				if (m_isFront) {
					m_btn_fanzhuan.setText("正面");
				} else {
					m_btn_fanzhuan.setText("反面");
				}
				break;
			case R.id.iv_handler://
				m_SlidingDrawer.animateOpen();
				break;
			case R.id.open_drawer:
				m_SlidingDrawer.animateClose();
				break;
			case R.id.about_qiye:
				startActivity(new Intent(Act_Main.this, AboutActivity.class));
				break;
			case R.id.btn_search:
				skipToBuwei();
				break;
			case R.id.tv_quanshen:
			case R.id.tv_quanshen1:
				skipToBuwei(BuWei.quanshen);
				break;
			case R.id.tv_tou:
				skipToBuwei(BuWei.toubu);
				break;
			case R.id.tv_jing:
				skipToBuwei(BuWei.jingbu);
				break;
			case R.id.tv_jian:
				skipToBuwei(BuWei.jianbu);
				break;
			case R.id.tv_xiong:
				skipToBuwei(BuWei.xiongbu);
				break;
			case R.id.tv_bei:
				skipToBuwei(BuWei.beibu);
				break;
			case 1:
				intent = new Intent(Act_Main.this, LiaoFaActivity.class);
				intent.putExtra("type", Btn1.getText().toString());
				startActivity(intent);
				break;
			case 2:
				intent = new Intent(Act_Main.this, LiaoFaActivity.class);
				intent.putExtra("type", Btn2.getText().toString());
				startActivity(intent);
				break;
			case 3:
				intent = new Intent(Act_Main.this, LiaoFaActivity.class);
				intent.putExtra("type", Btn3.getText().toString());
				startActivity(intent);
				break;
			case 4:
				intent = new Intent(Act_Main.this, LiaoFaActivity.class);
				intent.putExtra("type", Btn4.getText().toString());
				startActivity(intent);
				break;
			case 5:
				intent = new Intent(Act_Main.this, LiaoFaActivity.class);
				intent.putExtra("type", Btn5.getText().toString());
				startActivity(intent);
				break;
			case 6:
				intent = new Intent(Act_Main.this, LiaoFaChangshiActivity.class);
				intent.putExtra("type", Btn6.getText().toString());
				startActivity(intent);
				break;
			case R.id.tv_search:
				onsearchClick();
				break;
			case R.id.tv_ceshi:
				onTestClick();
				break;
			case R.id.tv_search_xuewei:
				search_xuewei();
				break;
			case R.id.btn_gushi:
				anli();
				break;
			case R.id.tv_tuijian:
				zuixinzixun();
				break;
		}
	}

	class ImageTouchListener implements OnTouchListener {

		int res;

		ImageTouchListener(int res) {
			this.res = res;
		}

		@Override
		public boolean onTouch(View arg0, MotionEvent arg1) {
			switch (arg1.getAction()) {
				case MotionEvent.ACTION_DOWN:
					m_Skip_Buwei_Intent = null;
					downx = (int) arg1.getX();
					downy = (int) arg1.getY();
					ImageView imageView = (ImageView) arg0;
					Bitmap bitmap = ((BitmapDrawable) imageView.getDrawable())
							.getBitmap();
					if (bitmap.getPixel(downx, downy) != 0) {
						reset(false, false, res);
						Log.e(TAG, "------");
						touch = true;
					} else {
					}
					break;
			}
			return false;
		}
	}

	class MoveReceiver extends BroadcastReceiver {

		boolean isRest = false;

		@Override
		public void onReceive(Context arg0, Intent arg1) {
			String action = arg1.getAction();
			if (action.equals(TouchRelativeLayout.ACTION_MOVE_)) {
				float x = arg1.getFloatExtra("x", 0);
				float y = arg1.getFloatExtra("y", 0);
				int moveXLneth = (int) Math.abs(x - downx);
				int moveYLenth = (int) Math.abs(y - downy);
				if (moveXLneth > 50 || moveYLenth > 50) {
					if (!touch) {
						return;
					}
					if (isRest) {
						return;
					}
					reset(false, true, m_isFront ? R.mipmap.bo_bo_yin_sel
							: R.mipmap.bo_bo_gang_sel);
					isRest = true;
				}
			} else if (action.equals(TouchRelativeLayout.ACTION_UP_)) {
				// touch = false;
				isRest = false;
				if (m_Skip_Buwei_Intent != null)
					startActivity(m_Skip_Buwei_Intent);
			}
		}
	}

	@Override
	public void onDrawerClosed() {
		m_iv_handler.setVisibility(View.GONE);
		m_open_drawer.setVisibility(View.VISIBLE);
	}

	@Override
	public void onDrawerOpened() {
		m_iv_handler.setVisibility(View.VISIBLE);
		m_open_drawer.setVisibility(View.GONE);
	}

	@Override
	public void onScrollChanged(ScrollType scrollType) {
		switch (scrollType) {
			case FLING:
				break;
			case IDLE:
				move();
				break;
			case TOUCH_SCROLL:
				break;
		}
	}

	/**
	 * 当按钮移动到一半时，把另一半也移动出来
	 */
	private void move() {
		int x = m_ScrollView.getScrollX();
		int move = 0;
		int yu = x % (m_DisWidth / 3);
		if (yu == 0) {
			move = 0;
		} else {
			if (yu < (m_DisWidth / 3) / 2) {
				move = -yu;
			} else {
				move = (m_DisWidth / 3) - yu;
			}
		}
		int fangxiang = m_ScrollView.getFangxiang();
		if (fangxiang == -1) {
			m_ScrollView.smoothScrollBy(-move, 0);
		} else {
			m_ScrollView.smoothScrollBy(move, 0);
		}
	}

	@Override
	public void run() {
		if (m_ScrollView.isTouch()) {
			return;
		}
		int x = m_ScrollView.getScrollX();
		if (x == m_DisWidth) {
			m_ScrollView.smoothScrollBy(-m_DisWidth / 3, 0);
			m_ScrollView.setFangxiang(-1);
		} else if (x == 0) {
			m_ScrollView.smoothScrollBy(m_DisWidth / 3, 0);
			m_ScrollView.setFangxiang(1);
		} else {
			int fangxiang = m_ScrollView.getFangxiang();
			m_ScrollView.smoothScrollBy(fangxiang == -1 ? -m_DisWidth / 3
					: m_DisWidth / 3, 0);
		}
		m_Handler.postDelayed(this, TIME);
	}

	private void skipToBuwei() {
		m_Skip_Buwei_Intent = new Intent(ctx, Act_Buwei.class);
		m_Skip_Buwei_Intent.putExtra("data", m_BuWei);
		startActivity(m_Skip_Buwei_Intent);
	}

	private void skipToBuwei(BuWei buWei) {
		m_Skip_Buwei_Intent = new Intent(ctx, Act_Buwei.class);
		m_Skip_Buwei_Intent.putExtra("data", buWei);
		startActivity(m_Skip_Buwei_Intent);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
	}
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			showAskDialog("确定退出程序?", "确定", "取消",
					new onDialogBtnClickListener() {
						@Override
						public void onClick() {
							ExitUtil.getInstant().exitApp(Act_Main.this);
							finish();
						}
					}, new onDialogBtnClickListener() {
						@Override
						public void onClick() {

						}
					});
		}
		return super.onKeyDown(keyCode, event);
	}
}
